package top.scsoul.voes.examination.service;

import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.RequestParam;
import top.scsoul.voes.common.core.domain.model.AnswerSheet;
import top.scsoul.voes.common.core.domain.model.ExameerOnlineVo;
import top.scsoul.voes.examination.entity.ExamRegistration;
import top.scsoul.voes.examination.entity.Examination;
import top.scsoul.voes.examination.entity.QuestionBank;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * (Examination)表服务接口
 *
 * @author guolei
 * @since 2021-07-21 15:37:35
 */
public interface ExaminationService {

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    Examination queryById(Integer id);

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    List<Examination> queryAllByLimit(int offset, int limit);

    /**
     * 查询多条数据
     *
     * @param examination
     * @param currentPage
     * @param pageSize
     * @return
     */
    PageInfo<Examination> queryAll(Examination examination, int currentPage, int pageSize);

    PageInfo<Examination> queryByUsername(String username, int currentPage, int pageSize);

    /**
     * 新增数据
     *
     * @param examination 实例对象
     * @return 实例对象
     */
    Examination insert(Examination examination);

    /**
     * 修改数据
     *
     * @param examination 实例对象
     * @return 实例对象
     */
    Examination update(Examination examination);

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    boolean deleteById(Integer id);

    void deleteByIds(List<Integer> ids);

    void export(List<Integer> ids, HttpServletResponse response) throws IOException;

    /**
     * 随机抽题目
     *
     * @param id            id
     * @param keyWord       关键字
     * @param singleChose   单选个数
     * @param multipleChose 多选
     * @param fillBlanks    填空题
     * @param judge         判断题
     */
    void randomQuestions(
            Integer id,
            String keyWord,
            Long singleChose,
            Long multipleChose,
            Long fillBlanks,
            Long judge,
            Long subjective);

    /**
     * 获取电子试卷
     *
     * @param examId 考试id
     */
    List<QuestionBank> testPaper(Integer examId);

    List<QuestionBank> testPaper(Integer examId, boolean answer);

    /**
     * 考生获取电子试卷
     *
     * @param username
     * @param examId
     * @return
     */
    List<QuestionBank> answerSheetTestPaper(String username, Integer examId);


    /**
     * 定时任务
     *
     * @param examId
     * @param username
     * @param answerSheet
     */
    void submitAnswerSheet(Integer examId, String username,
                           List<AnswerSheet> answerSheet);

    /**
     * @param examId
     * @return
     */
    List<ExamRegistration> getOnlineExameeInfo(Integer examId);

    /**
     * 检测状态
     *
     * @param examId
     * @return
     */
    Integer checkState(Integer examId);

    /**
     * .考试心跳
     *
     * @param exameerOnlineVo
     * @return
     */
    void exameeOnliner(ExameerOnlineVo exameerOnlineVo);

    /**
     * 获取心跳  监控台
     *
     * @param examId
     * @return
     */
    Map<String, Object> getOnlineExameeHeat(Integer examId);

}